import xadmin

from apps.courses.models import Course, Lesson, Vedio, CourseResource, CourseTag

class GlobalSettings(object):
    site_title  = "后台管理系统"
    site_footer = "学习网"
    # menu_style = "accordion"
class BaseSettings(object):
    enable_themes = True
    use_bootswatch = True

class CourseAdmin(object):

    # 显示列
    list_display = ["name", "desc", "detail", "learn_times", "students"]
    # 搜索列
    serach_fields = ["name", "desc", "detail", "students"]
    # 过滤
    list_filter = ["name", "desc", "teacher__name", "detail", "learn_times", "students"]
    # 编辑
    list_editable = ["degree", "desc"]

class LessonAdmin(object):

    list_display = ["course", "name", "add_time"]

    serach_fields = ["course", "name"]
    #外键过滤双下划线
    list_filter = ["course__name", "name", "add_time"]
class CourseTagAdmin(object):

    list_display = ["course", "tag", "add_time"]

    serach_fields = ["course", "tag"]
    #外键过滤双下划线
    list_filter = ["tag", "add_time"]



class VedioAdmin(object):
    list_display = ["lesson", "name", "add_time"]

    serach_fields = ["lesson", "name"]

    list_filter = ["lesson", "name", "add_time"]


class CourseResourceAdmin(object):
    list_display = ["course", "name", "file"]

    serach_fields = ["course", "name"]

    list_filter = ["course", "name", "add_time"]


xadmin.site.register(Course, CourseAdmin)
xadmin.site.register(Lesson, LessonAdmin)
xadmin.site.register(Vedio, VedioAdmin)
xadmin.site.register(CourseResource, CourseResourceAdmin)
xadmin.site.register(CourseTag, CourseTagAdmin)
xadmin.site.register(xadmin.views.CommAdminView, GlobalSettings)
xadmin.site.register(xadmin.views.BaseAdminView, BaseSettings)